<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>创建一个新的正则表达式</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="class.mongoregex.html">MongoRegex</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mongoregex.tostring.html">MongoRegex::__toString</a></div>
 <div class="up"><a href="class.mongoregex.html">MongoRegex</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="mongoregex.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoRegex::__construct</h1>
  <p class="verinfo">(PECL mongo &gt;= 0.8.1)</p><p class="refpurpose"><span class="refname">MongoRegex::__construct</span> &mdash; <span class="dc-title">创建一个新的正则表达式</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mongoregex.construct-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>MongoRegex::__construct</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$regex</code></span>
   )</div>

  <p class="para rdfs-comment">
   创建一个新的正则表达式。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-mongoregex.construct-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>

      <em><code class="parameter">regex</code></em>
     </dt>

     <dd>

      <p class="para">
       以 /expr/flags 形式的正则表达式字符串。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-mongoregex.construct-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回一个新的正则表达式。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-mongoregex.construct-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-1467">
    <p><strong>Example #1 <span class="function"><strong>MongoRegex::__construct()</strong></span> 例子</strong></p>
    <div class="example-contents"><p>这个例子使用了正则表达式来查询包含匹配正则表达式的用户名的所有文档。</p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$joe_search&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">MongoRegex</span><span style="color: #007700">(</span><span style="color: #DD0000">"/j[o0]e/i"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$cursor&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$collection</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">find</span><span style="color: #007700">(array(</span><span style="color: #DD0000">"username"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$joe_search</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-mongoregex.construct-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="mongoregex.tostring.html" class="methodname" rel="rdfs-seeAlso">MongoRegex::__toString()</a> - 正则表达式的字符串表达形式</span></li>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="class.mongoregex.html">MongoRegex</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mongoregex.tostring.html">MongoRegex::__toString</a></div>
 <div class="up"><a href="class.mongoregex.html">MongoRegex</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
